package xin.marcher.module.common.enums.seller;

import java.util.HashMap;
import java.util.Map;

/**
 * 卖家类型枚举
 */
public enum SellerTypeEnum {

    /**
     * 所有卖家类型
     */
    ALL(0, "全部"),

    /**
     * 自营
     */
    SELF(1, "自营"),

    /**
     * 第三方店铺 Platform Open Plan
     */
    POP(2, "第三方店铺");

    private Integer code;

    private String value;

    SellerTypeEnum(Integer code, String value) {
        this.code = code;
        this.value = value;
    }

    public Integer getCode() {
        return code;
    }

    public String getValue() {
        return value;
    }

    public static Map<Integer, String> toMap() {
        Map<Integer, String> map = new HashMap<>(16);
        for (SellerTypeEnum element : SellerTypeEnum.values()) {
            map.put(element.getCode(), element.getValue());
        }
        return map;
    }

    public static SellerTypeEnum getByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (SellerTypeEnum element : SellerTypeEnum.values()) {
            if (code.equals(element.getCode())) {
                return element;
            }
        }
        return null;
    }

}